﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Management;
using System.Text;
using System.Threading.Tasks;

namespace Common.Utils
{
    public class ComputerHelp
    {
        public static void Shutdown(int time)
        {
            Process.Start("c:/windows/system32/shutdown.exe", "-s -t " + time);
        }

        public static void UnShutdown()
        {
            Process.Start("c:/windows/system32/shutdown.exe", "-a" );
        }

        public static string GetCpuInfo()
        {
            var strCpu = "";
            var myCpu = new ManagementClass("win32_Processor"); //ManagementClass:通用信息模型 (CIM) 管理类
            var myCpuConnection = myCpu.GetInstances();
            foreach (var myObject in myCpuConnection)
            {
                strCpu = myObject.Properties["Processorid"].Value.ToString();
                break;
            }
            return strCpu;
        }
    }

}
